package com.lh.eemsserver.Mapper;

import com.lh.eemsserver.po.Admin;
import com.lh.eemsserver.po.User;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
public interface AdminMapper {

    @Update("update eemsdb.user set userName=#{userName},password=#{password} where userID=#{userID}")
    public int renewUserInfo(User user);
    //用户找回密码更新用户信息

    @Insert("insert into eemsdb.user (userName, password, role) values (#{userName},#{password},#{role});")
    public int newUserInfo(User user);
    //用户注册新建信息
    @Select("select * from eemsdb.user;")
    public List<User> listAllUser();
    //创建一个账号后显示id信息提示、以及在列表显示账户信息
    @Select("select * from eemsdb.admin where adminID=#{adminID} and password=#{password}")
    public Admin getAdminName(Admin admin);
    //既适用于登录又适用于登陆成功后界面右上角信息展示
    @Update("update eemsdb.admin set adminName=#{adminName}, password=#{password} where adminID=#{adminID}")
    public int renewAdminInfo(@RequestBody Admin admin);
    //更新管理员信息,更新后不能通过之前设置的sessionstorage进行取值，而要通过ID进行再次取值，保证取到的是实时的数据
    @Select("select * from eemsdb.admin where adminID=#{adminID};")
    public Admin getAdminInfo(Admin admin);
    //更新后不能通过之前设置的sessionstorage进行取值，而要通过ID进行再次取值，保证取到的是实时的数据
    @Delete("delete from eemsdb.user where userID=#{userID}")
    public int delUserInfo(User user);
    //删除用户信息
}
